home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / confx / confx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  1.5 KB  |  71 lines

  1. #include <exec/exec.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <clib/exec_protos.h>
  6. struct ConfBase
  7. {
  8.   char Handle[31];
  9.   ULONG NewSinceDate, ConfRead,ConfYM;
  10.   ULONG Bytes_Download,Bytes_Upload;
  11.   ULONG Daily_Bytes_Limit,Daily_Bytes_Dld;
  12.   USHORT Upload,Downloads,RatioType,Ratio,Messages_Posted;
  13.   UWORD Access;
  14.   UWORD Active;
  15. };
  16. struct ConfBase Conf;
  17. void sr(char *s);
  18. main(int argc,char *argv[])
  19. {
  20.    char ConfLocal[200];
  21.    FILE *fi;
  22.    int totalrecords=0;
  23.    if(argc!=3)
  24.    {
  25.      printf("ConfDB version 1.0, written by Joseph Hodge\n");
  26.      printf("usage: ConfDB <conf location> <num records>\n");
  27.      printf("   ie: ConfDB BBS:Confs/PD  300\n");
  28.      exit(0);
  29.    }
  30.    
  31.   strcpy(ConfLocal,argv[1]);
  32.   totalrecords=atoi(argv[2]);
  33.   sr(ConfLocal);
  34.     if(ConfLocal[strlen(ConfLocal)-1]!=':' && ConfLocal[strlen(ConfLocal)-1]!='/') strcat(ConfLocal,"/");
  35.   strcat(ConfLocal,"Conf.DB");
  36.   fi=fopen(ConfLocal,"wb");
  37.   if(fi==NULL)
  38.   {
  39.     printf("Error, can't generate ConfBase\n");
  40.     exit(0);
  41.   }
  42.   
  43.  strcpy(Conf.Handle,"");
  44.  Conf.NewSinceDate=0L;
  45.  Conf.ConfRead=0L;
  46.  Conf.ConfYM=0L;
  47.  Conf.Access=0;
  48.  Conf.Bytes_Download=Conf.Bytes_Upload=0L;
  49.  Conf.Upload=Conf.Downloads=0; Conf.RatioType=0;Conf.Ratio=0;
  50.  Conf.Messages_Posted=0;
  51.  Conf.Active=0;
  52.  
  53.   while(totalrecords)
  54.   {
  55.     fwrite((APTR)&Conf,sizeof(struct ConfBase),1,fi);
  56.     totalrecords--;
  57.   }
  58.   fclose(fi);
  59.   exit(0);
  60. }
  61. void sr(char *s)
  62. {
  63.    register int i;
  64.    i=strlen(s)-1;
  65.    while(i>-1)
  66.    {
  67.      if(*(s+i)<=32) *(s+i)='\0'; else break;
  68.      i--;
  69.    }
  70. }
  71.